package com.kungkhies.mvc.login;

import java.util.Map;
import static org.springframework.web.bind.annotation.RequestMethod.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController
{
    @RequestMapping(value={"/login"}, method = RequestMethod.GET)
    public String showLoginPage(@RequestParam(value="login_error", required=false) boolean login_error, Map<String, Object> model)
    {
        if (login_error == true) {
            // Assign an error message
            model.put("error_message", "Login failed. Bad credentials.");
        } else {
            model.put("error_message", "");
        }
        return "login";
    }   
}
